<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>React之简单入门实例（计时器）</title>
    <link rel="stylesheet" href="css/base.css"/>
    <script src="js/react.development.js"></script>
    <script src="js/react-dom.development.js"></script>
    <script>
        var ea = React.createClass({
            render: function () {
                var elapsed = Math.round(this.props.elapsed / 100);
                var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0');
                var message = '开始计时：' + seconds + ' 秒';

                return React.DOM.p(null, message);
            }
        });

        var eaf = React.createFactory(ea);
        var startTime = new Date().getTime();
        setInterval(function () {
            ReactDOM.render(
                eaf({elapsed: new Date().getTime() - startTime}), document.getElementById('timer')
            );
        }, 1000);
    </script>
</head>
<body>
<div id="timer"></div>
</body>
</html>